package com.aaa.controller;

import com.aaa.entity.Roomtype;
import com.aaa.service.RoomtypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Roomtype)表控制层
 *
 * @author makejava
 * @since 2022-01-12 13:27:05
 */
@RestController
@RequestMapping("roomtype")
public class RoomtypeController {
    /**
     * 服务对象
     */
    @Resource
    private RoomtypeService roomtypeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Roomtype selectOne(Integer id) {
        return this.roomtypeService.queryById(id);
    }

//    添加房间类型
    @RequestMapping("saveRoomType")
    public Object saveRoomType(Roomtype roomtype){
        Roomtype roomtype1=roomtypeService.insert(roomtype);
        return roomtype1;
    }

//    查看房间类型信息
    @RequestMapping("selectRoomType")
    public Object selectRoomType(Integer pageNum,Integer pageSize){
        List<Roomtype> roomtype=roomtypeService.queryAllByLimit(pageNum,pageSize);
        return roomtype;
    }

    @RequestMapping("deleteRoomTypeByid")
    public Boolean deleteRoomTypeByid(Integer id){
        Boolean state=roomtypeService.deleteById(id);
        return state;
    }
}